import java.util.Arrays;

public class ch05_1_1 {
    public static void main(String[] args) {
        //排序
        int[] a = {1,5,2,9,3};
        System.out.println("排序前：" + Arrays.toString(a));
        sort(a);
        System.out.println("排序后：" + Arrays.toString(a));
    }

    public static void sort(int[] a) {
        for (int i = 0; i < a.length - 1; i++) {
            int min = i;
            for (int j = i+1; j < a.length ; j++) {
                if (a[min] < a[j]){
                    min = j;
                }
            }
            if (min != i){
                int tmp = a[min];
                a[min] = a[i];
                a[i] = tmp;
            }
        }
    }
}
